<?php
/**
 * Creates some statistics out of the GEDCOM information.
 * We will start with the following possibilities
 * number of persons -> periodes of 10 years from 1700-2010
 * age -> periodes of 10 years (different for 0-1,1-5,5-10,10-20 etc)
 *
 * Genmod: Genealogy Viewer
 * Copyright (C) 2005 Genmod Development Team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Genmod
 * @subpackage Lists
 * @version $Id: statisticsplot.php 9 2013-12-30 17:16:11Z boudewijn.sjouke@gmail.com $
 */
 
/**
 * Inclusion of the configuration file
*/
require("config.php");
require_once($GM_BASE_DIRECTORY."includes/functions_plot.php");

//-- You should install JpGraph routines on your computer. I implemented them in genmod/modules/jpgraph/
//=== You have to check if the reference to internal subroutines (like plotmark.inc) has the right path
//=== I had to change them (by adding the directory) to jpgraph/plotmark.inc 
//-- Please check this with any availability test

//-- The info below comes from www.php.net when looking at functions

CheckPlotExtensions();

include ("modules/jpgraph/jpgraph.php");
include ("modules/jpgraph/jpgraph_line.php");
include ("modules/jpgraph/jpgraph_bar.php");

function bimo($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $persgeg[$i]["mbirth"];
	if ($z_as == 301) $ys = $persgeg[$i]["sex"]-1;
	else $ys = $persgeg[$i]["ybirth"];

 	if ($m > 0)	{	
		//--print "bimo:".$ys." : ".$m."<br>";
		fill_ydata($ys,$m-1,1);
		$n1++;
	}
}

function bimo1($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $famgeg[$i]["mbirth1"];
	if ($z_as == 301) $ys = $famgeg[$i]["sex1"]-1;
	else $ys = $famgeg[$i]["ybirth1"];

 	if ($m > 0)	{
		//--print "bimo:".$ys." : ".$m."<br>";
		fill_ydata($ys,$m-1,1);
		$n1++;
	}
}

function demo($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $persgeg[$i]["mdeath"];
	if ($z_as == 301) $ys= $persgeg[$i]["sex"]-1;
	else $ys= $persgeg[$i]["ybirth"];

	if ($m > 0) {
		fill_ydata($ys,$m-1,1);
		$n1++;
	}
}

function mamo($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $famgeg[$i]["mmarr"]; 
	$y= $famgeg[$i]["ymarr"];
	//--print "mamo:".$y." : ".$m."<br>";
	if ($m > 0)	{
		fill_ydata($y,$m-1,1);
		$n1++;
	}
}

function mamo1($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $famgeg[$i]["mmarr1"]; 
	$y= $famgeg[$i]["ymarr1"];
	//--print "mamo:".$y." : ".$m."<br>";
	if ($m > 0) {
		fill_ydata($y,$m-1,1);
		$n1++;
	}
}

function mamam($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$m= $famgeg[$i]["mmarr"]; $y= $famgeg[$i]["ymarr"];
	//--print "mamo:".$y." : ".$m."<br>";
	if ($m > 0)	{
		$m2= $famgeg[$i]["mbirth1"]; 
		$y2= $famgeg[$i]["ybirth1"]; 
		if ($z_as == 301) $ys= $famgeg[$i]["sex1"] - 1;
		else $ys= $famgeg[$i]["ybirth1"];
		if ($m2 > 0) {
			$mm= ($y2 - $y) * 12 + $m2 - $m;
			//--print $i.":".$y."-".$m."::".$y2."-".$m2."<br>";
			fill_ydata($ys,$mm,1);
			$n1++;
		}
	}
}

function agbi($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$yb= $persgeg[$i]["ybirth"];
	$yd= $persgeg[$i]["ydeath"];
	if ($yb > 0 && $yd > 0)	{
		$age= $yd - $yb;
		if ($z_as == 301) $yb= $persgeg[$i]["sex"]-1;
		fill_ydata($yb,$age,1);
		//-- print "leeftijd:" . $i . ":" . $yb . ":" . $yd . ":" . $age . "<br>";
		$n1++;
	}
}

function agde($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$yb= $persgeg[$i]["ybirth"];
	$yd= $persgeg[$i]["ydeath"];
	if ($yb > 0 && $yd > 0) {	
		$age= $yd - $yb;
		if ($z_as == 301) $yd= $persgeg[$i]["sex"]-1;
		fill_ydata($yd,$age,1);
		//-- print "leeftijd:" . $i . ":" . $yb . ":" . $yd . ":" . $age . "<br>";
		$n1++;
	}
}

function agma($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$ym= $famgeg[$i]["ymarr"];
	//--print "mamo:".$y." : ".$m."<br>";
	if ($ym > 0) {
		$xfather= $famgeg[$i]["male"];
		$xmother= $famgeg[$i]["female"];
		if (!empty($xfather)) $j= $key2ind[$xfather];
		if (!empty($xmother)) $j2= $key2ind[$xmother];
		$ybirth= -1; 
		$ybirth2= -1; 
		$age= 0; 
		$age2= 0;
		if (isset($j)  && ($xfather !== "")) $ybirth= $persgeg[$j]["ybirth"];
		if (isset($j2) && ($xmother !== "")) $ybirth2= $persgeg[$j2]["ybirth"];
		$z= $ym; 
		$z1= $ym;
		if ($z_as == 301) {
			$z= 0; 
			$z1= 1;
		}
		if ($ybirth > -1) {
			$age= $ym - $ybirth; 
			fill_ydata($z,$age,1); 
			$n1++;
		}
		if ($ybirth2 > -1) {
			$age2= $ym - $ybirth2; 
			fill_ydata($z1,$age2,1); 
			$n1++;
		}
		// if ($age < 15 || $age > 70) {
			//--	print ("huw:" . $xfather . ":" . $xmother . ":" . $ym . ":" . $age . ":" .$age2 . ":" . $mm . "<BR>");
		// }
	}
}

function agma1($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$ym= $famgeg[$i]["ymarr"];
	//--print "mamo:".$y." : ".$m."<br>";
	if ($ym > -1) {
		$xfather= $famgeg[$i]["male"];
		$xmother= $famgeg[$i]["female"];
		$j= $key2ind[$xfather];
		$j2= $key2ind[$xmother];
		$ybirth= -1; 
		$ybirth2= -1; 
		$age= 0; 
		$age2= 0;
		if (isset($j) && $xfather !== "") {
			$ybirth=  $persgeg[$j]["ybirth"];  
			$ymf= $persgeg[$j]["ymarr1"];
		}
		if (isset($j2) && $xmother !== "") { 
			$ybirth2= $persgeg[$j2]["ybirth"]; 
			$ymm= $persgeg[$j2]["ymarr1"];
		}
		$z= $ym; 
		$z1= $ym; 
		if ($z_as == 301) {
			$z= 0; 
			$z1= 1;
		}
		if ($ybirth > -1 && $ymf > -1 && $ym == $ymf) {
			$age= $ym - $ybirth; 
			fill_ydata($z,$age,1); 
			$n1++;
		}
		if ($ybirth2 > -1 && $ymm > -1 && $ym == $ymm) {
			$age2= $ym - $ybirth2; 
			fill_ydata($z1,$age2,1); 
			$n1++;
		}
//		if ($age < 15 or $age > 70) {
			//--	print ("huw:" . $xfather . ":" . $xmother . ":" . $ym . ":" . $age . ":" .$age2 . ":" . $mm . "<BR>");
//		}
	}
}


function nuch($i) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;

	$c= $famgeg[$i]["mmarr"]; 
	$y= $famgeg[$i]["ymarr"];
	//--print "mamo:".$y." : ".$m."<br>";
	//--	if ($m > 0)
	//{
	fill_ydata($y,$c,1);
	$n1++;
	//}
}


function fill_ydata($z,$x,$val) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;
	global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage, $man_vrouw;
	global $gm_lang;
	
	//--	calculate index $i out of given z value
	//--	calculate index $j out of given x value

	//--print "z,x,val,xgrenzen,zgrenzen".$z .":".$x.":".$val.":".$xgiven.":".$zgiven."<br>";
	if ($xgiven) {
		$j= $x;
	}
	else {
		$j = 0;
		while ($x > $xgrenzen[$j] && $j < $xmax) {
			//--print "xgrenzen:".$xgrenzen[$j].":".$x."==<br>"; 
			$j++;
		}
	}
	if ($zgiven) {
		$i= $z;
	}
	else {
		$i=0;
		while ($z > $zgrenzen[$i] && $i < $zmax) {
			//--print "zgrenzen:".$zgrenzen[$i].":".$z."==<br>";
			$i++;
		}
	}
	if (isset($ydata[$i][$j])) $ydata[$i][$j] += $val;
	else $ydata[$i][$j] = $val;
	//--	print "z:" . $z . ", x:" . $x . ", i:" . $i . ", j:" . $j .", val:" . $val . "<BR>";
}

function myplot($mytitle,$n,$xdata,$xtitle,$ydata,$ytitle,$legend) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;
	global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage;
	global $gm_lang, $colors;
	global $showShadow, $valuePos, $graphSize, $value_angle, $screenRes, $windowRes;

	$b= array();

	$graph_width = $graph_height = -1;
	if (($graphSize == "autoScreen") || ($graphSize == "autoWindow")) {
		$new_size = array();
		if ($graphSize == "autoScreen") $new_size = explode("x",$screenRes);
		else if ($graphSize == "autoWindow") $new_size = explode("x",$windowRes);
		if (count($new_size >= 2)) {
			$graph_width = ($new_size[0]*7)/8;
			$graph_height = ($graph_width*4)/7;
		}
	}
	if (($graph_width == -1) || ($graph_height == -1)) {
		$new_size = array();
	        $new_size = explode("x",$graphSize);
		if (count($new_size >= 2)) {
			$graph_width = $new_size [0];
			$graph_height = $new_size [1];
		}
	}
	if (($graph_width == -1) || ($graph_height == -1)) {
		$graph_width = 700; $graph_height = 400;
	}
	$graph= new Graph($graph_width,$graph_height,"auto");

	$graph-> SetScale("textlin");
	$graph->title->Set($mytitle);
	$graph->title->SetColor("darkred");
	$graph->xaxis->SetTickLabels($xdata);
	$graph->xaxis->title->Set($xtitle);
	$graph->yaxis->title->Set($ytitle);
	$graph->yaxis->scale->SetGrace(20);
	$graph->xaxis->scale->SetGrace(20);
	//--print "myplot".$n.":".$percentage . ":".$xmax."<br>";
	$groupBarArray = array();
	for($i=0; $i<$n; $i++) {
		if ($percentage){
			$sum= 0;
			for ($j=0; $j<$xmax;$j++) {
				$sum= $ydata[$i][$j] + $sum;
			}
			for ($j=0; $j<$xmax; $j++) {
				if ($sum > 0) {
					$ynew= $ydata[$i][$j] / $sum * 100;
					settype($ynew, 'integer'); 
					$ydata[$i][$j]= $ynew; 
				}
			}
		}
		$b[$i] = new BarPlot($ydata[$i]);
		$b[$i] ->SetFillColor($colors[$i]);
		$b[$i] ->Setlegend($legend[$i]);
		if ($valuePos != "none") {
			$b[$i] ->value->Show();
			$b[$i] ->SetValuePos($valuePos);
		}
		$b[$i] ->value->SetFormat('%d');
		if ($value_angle != 0) {
			// would look nicer with font & angle, but
			// which font? TTF font is required for angle
			//$b[$i] ->value->SetFont(FF_VERA);
			$b[$i] ->value->SetAngle($value_angle);
		}
		if ($showShadow == "yes") $b[$i] ->SetShadow();
		$groupBarArray[]=$b[$i];
	}
	$accbar = new GroupBarPlot($groupBarArray);

	$graphFile = tempnam("/tmp", "GM");
	$graph-> Add($accbar);
	$graph-> Stroke($graphFile);
	$tempVarName = "V".time();
	unset($_SESSION["image_data"]);			// Make sure imageflush.php
	$_SESSION[$tempVarName] = $graphFile;	//   uses the right image source
	$imageSize = getimagesize($graphFile);
	if ($imageSize===false) {
		unset($imageSize);
		$imageSize[0] = 300;
		$imageSize[1] = 300;
	}
	$titleLength = strpos($mytitle."\n", "\n");
	$title = substr($mytitle, 0, $titleLength);
	print "<center>";
	print "<img src=\"imageflush.php?image_type=png&amp;image_name=$tempVarName\" width=\"$imageSize[0]\" height=\"$imageSize[1]\" border=\"0\" alt=\"$title\" title=\"$title\" />";
	print "</center><br /><br />";
}

function calc_axis($xas_grenzen) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;
	global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage, $man_vrouw;
	global $gm_lang;

	//calculate xdata and zdata elements out of given POST values
	$hulpar= array();

	$hulpar= explode(",",$xas_grenzen);
	//--print "string x_as".$xas_grenzen."<BR>";
	//--for ($k=0;$k<10;$k++) {print "grenzen x_as:" . $k .":" . $hulpar[$k];}print "<br>";
	$i=1; 
	$xdata[0]= "<" . "$hulpar[0]"; 
	$xgrenzen[0]= $hulpar[0]-1;
	while (isset($hulpar[$i])) {
		$i1= $i-1; 
		if (($hulpar[$i] - $hulpar[$i1]) == 1) $xdata[$i]= "$hulpar[$i1]";
		else $xdata[$i]= "$hulpar[$i1]" . "-" . "$hulpar[$i]";
		$xgrenzen[$i]= $hulpar[$i]; 
		$i++;
		//--print " xgrenzen:".$i.":".$xgrenzen[$i-1].":".$xdata[$i-1].":<BR>";
	}
	$xmax= $i; 
	$xmax1= $xmax-1; 
	$xdata[$xmax]= ">" . "$hulpar[$xmax1]"; 
	$xgrenzen[$xmax]= 10000;
	$xmax= $xmax+1;
	if ($xmax > 20) $xmax=20;
}

//regel 389
function calc_legend($grenzen_zas) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;
	global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage, $man_vrouw;
	global $gm_lang, $colors;

	// calculate the legend values
	$hulpar= array();
	//-- get numbers out of $grenzen_zas

	$hulpar= explode(",",$grenzen_zas);
	//--print "string z_as".$grenzen_zas."<BR>";
	//--for ($k=0;$k<10;$k++) {print "grenzen z_as" . $k .":" . $hulpar[$k];} print "<br>";
	$i=1; 
	$legend[0]= "<" . "$hulpar[0]"; 
	$zgrenzen[0]= $hulpar[0]-1;
	while (isset($hulpar[$i])) {
		$i1= $i-1; 
		$legend[$i]= "$hulpar[$i1]" . "-" . "$hulpar[$i]"; 
		$zgrenzen[$i]= $hulpar[$i]; 
		$i++;
		//--print " zgrenzen:".$i.":".$zgrenzen[$i-1].":".$legend[$i-1].":<BR>";
	}
	$zmax= $i; 
	$zmax1= $zmax-1; 
	$legend[$zmax]= ">" . "$hulpar[$zmax1]"; 
	$zgrenzen[$zmax]= 10000;
	$zmax= $zmax+1;
	if ($zmax > count($colors)) $zmax=count($colors);
}

//--------------------nr,-----bron ,xgiven,zgiven,title, xtitle,ytitle,grenzen_xas, grenzen-zas,functie,
function set_params($current, $indfam, $xg,  $zg, $titstr,  $xt, $yt, $gx, $gz, $myfunc) {
	global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg, $key2ind, $n1;
	global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage, $man_vrouw;
	global $gm_lang, $MON_SHORT;

	$monthdata= array();
	$monthdata= explode(",",$MON_SHORT);
	foreach ($monthdata as $key=>$month) {
		$monthdata[$key] = utf8_decode($month);
	}

	//--print "xas: " . $x_as . " current: " . $current . "<br>";
	if ($x_as == $current) {
		$xgiven= $xg; 
		$zgiven= $zg;
		$title= $gm_lang["$titstr"];
		$xtitle= $gm_lang["$xt"]; 
		$grenzen_xas= $gx; 
		$grenzen_zas= $gz;
		if ($xg == true) {
			$xdata=$monthdata; 
			$xmax=12;
		}
		else calc_axis($grenzen_xas);
		calc_legend($grenzen_zas);
	
		$percentage= false; 
		switch ($y_as) {
		default: //case 201:
			$percentage= false; 
			$ytitle= $gm_lang["stplnum"];
			break;
		case 202:
			$percentage= true;  
			$ytitle= $gm_lang["stplperc"];
			break;
		}
	
		$man_vrouw= false;
		switch ($z_as) {
		case 300:
			$zgiven= false;
			$legend[0]= "all"; 
			$zmax=1; 
			$zgrenzen[0]= 100000;
			break;
		case 301:
			$man_vrouw= true; 
			$zgiven= true;
			$legend[0]= $gm_lang["male"]; 
			$legend[1]= $gm_lang["female"]; 
			$zmax=2; 
			$xtitle= $xtitle . $gm_lang["stplmf"];
			break;
		default: //case 302:
			$xtitle= $xtitle . $gm_lang["stplipot"];
			break;
		}
	
		//-- reset the data array
		for($i=0; $i<$zmax; $i++) {
			for($j=0; $j<$xmax; $j++) {
				$ydata[$i][$j]= 0;
			}
		}
	
		if ($indfam == "IND") $nrmax= $nrpers;
		else $nrmax= $nrfam;
		//--print "nmax".$nrmax.":".$xg.":".$zg.":"."<br>";
		if (!function_exists($myfunc)) {
			print "not implemented function" . $myfunc . "<br />";
			exit;
		}
		for ($i=0; $i < $nrmax; $i++) {	
			//--print "main:" . $i . "<br>";
			$myfunc($i);
		}
		$hstr= utf8_decode($title) . "\n" . utf8_decode($gm_lang["stplnumof"]) . " N=" . $n1 . " (max= " . $nrmax. ").";
		myplot($hstr,$zmax,$xdata,utf8_decode($xtitle),$ydata,utf8_decode($ytitle),$legend);
	}
}

//--	========= start of main program =========
global $x_as,$y_as, $z_as, $nrfam, $famgeg, $nrpers, $persgeg,$key2ind;
global $legend, $xdata, $ydata, $xmax, $xgrenzen, $zmax, $zgrenzen, $xgiven,$zgiven, $percentage, $man_vrouw;
global $colors;

//-- Out of range values or no values entered; redirect tot statistics.php
if (!isset($x_as) || !isset($y_as) || !isset($z_as) || $x_as <  11 || $x_as >  21 || $y_as < 201 ||$y_as > 202 || $z_as < 300 ||$z_as > 302) {
	header("Location: statistics.php");
	exit;
}

$legend= array();
$xdata= array();
$ydata= array();
$xgrenzen= array();
$zgrenzen= array();
$famgeg = array();
$persgeg= array();
$key2ind= array();
$colors= array();

	if (count($colors) < 1) {
//LERMAN - with a maximum of 7 entries in the Z-axis (years), 8 colors are needed.
// This will automatically control the number of BarPlot objects created & passed to GroupBarPlot and calc_legend().
// Increasing the maximum entries will need more colors. First color is also used for male, second for female.
		$colors= array("blue","red","orange","brown","green","yellow","pink","magenta");
//Ideas for other ways of using colors. The trick is to make them (a) easily distinguishable and (b) not looking obnoxious
// 1) use the 200 names colors provided by JpGraph. These will not necessarily be (a)
//		$myrgb = new RGB();
//		$colors = array_keys($myrgb->rgb_table);
// If this "if" block were after the $graph was created, could do the following. However, $zmax would not be set up right.
//		$colors = array_keys($graph->img->rgb->rgb_table);
//		sort($colors);
// 2) Algorithmically create a pile of colors using pure PHP
// start with primary colors (male, female, other)
//		$colors[]="#0000ff";$colors[]="#ff0000";$colors[]="#00ff00";
// continuing on with some algorithm
// 3) tie into the themetable in jpgraph/src/jpgraph_pie.php
//	it uses the $colors array (from #1 above) indexed by value such as $colors(12);
	}

if (isset ($NEW_VALUE_ANGLE)) $value_angle = $NEW_VALUE_ANGLE;
else $value_angle = 0;

// Save the input variables
$savedInput = array();
$savedInput["x_as"] = $x_as;
$savedInput["y_as"] = $y_as;
$savedInput["z_as"] = $z_as;
$savedInput["xasGrLeeftijden"] = $xasGrLeeftijden;
$savedInput["xasGrMaanden"] = $xasGrMaanden;
$savedInput["xasGrAantallen"] = $xasGrAantallen;
$savedInput["zasGrPeriode"] = $zasGrPeriode;
$savedInput["showShadow"] = $showShadow;
$savedInput["valuePos"] = $valuePos;
$savedInput["graphSize"] = $graphSize;
$_SESSION[$GEDCOM."statisticsplot"] = $savedInput;
unset($savedInput);

//--	print " sort, x_as:" . $x_as . ", y_as:". $y_as . ", x_as:". $z_as . ", xas_gr_leef:" . $xas_grenzen_leeftijden . ", xas_gr_maan:" . $xas_grenzen_maanden . ", xas_gr_aant:" . $xas_grenzen_aantallen . ", zas_gr_peri:" . $zas_grenzen_periode . "<BR>";

print_header($gm_lang["statistiek_list"]);
print "\n\t<center><h2>".$gm_lang["statistiek_list"]."</h2>\n\t";
print "</center>";

//--print ("aantal namen, families, male and female=".$nrpers . ":" . $nrfam . ":" $nrman . ":" $nrvrouw . "<BR>");

GetPlotData();

$xstr="";
$ystr="";
//regel 508
//-- Set params for request out of the information for plot
$g_xas= "1,2,3,4,5,6,7,8,9,10,11,12"; //should not be needed. but just for month
$xgl= $xasGrLeeftijden;
$xgm= $xasGrMaanden;
$xga= $xasGrAantallen;
$zgp= $zasGrPeriode;

//-- end of setting variables	

//---------nr,bron ,xgiven,zgiven,	title,      xtitle,   ytitle, grenzen_xas, grenzen-zas,,
//--print "true false". true .":" . false ."<br>";
set_params(11,"IND", true,  false, "stat_11_mb",  "stplmonth", $y_as, $g_xas, $zgp,"bimo");  //plot aantal geboorten per maand
set_params(12,"IND", true,  false, "stat_12_md",  "stplmonth", $y_as, $g_xas, $zgp,"demo");  //plot aantal overlijdens per maand
set_params(13,"FAM", true,  false, "stat_13_mm",  "stplmonth", $y_as, $g_xas, $zgp,"mamo");  //plot aantal huwelijken per maand
set_params(14,"FAM", true,  false, "stat_14_mb1", "stplmonth", $y_as, $g_xas, $zgp,"bimo1"); //plot aantal 1e geboorten per huwelijk per maand
set_params(15,"FAM", true,  false, "stat_15_mm1", "stplmonth", $y_as, $g_xas, $zgp,"mamo1"); //plot 1e huwelijken per maand
set_params(16,"FAM", false, false, "stat_16_mmb", "stplmarrbirth",$y_as, $xgm,$zgp,"mamam"); //plot tijd tussen 1e geboort en huwelijksdatum
set_params(17,"IND", false, false, "stat_17_arb", "stplage",   $y_as, $xgl,   $zgp,"agbi");  //plot leeftijd t.o.v. geboortedatum
set_params(18,"IND", false, false, "stat_18_ard", "stplage",   $y_as, $xgl,   $zgp,"agde");  //plot leeftijd t.o.v. overlijdensdatum
set_params(19,"FAM", false, false, "stat_19_arm", "stplage",   $y_as, $xgl,   $zgp,"agma");  //plot leeftijd op de huwelijksdatum
set_params(20,"FAM", false, false, "stat_20_arm1","stplage",   $y_as, $xgl,   $zgp,"agma1"); //plot leeftijd op de 1e huwelijksdatum
set_params(21,"FAM", false, false, "stat_21_nok", "stplnumbers",$y_as,$xga,   $zgp,"nuch");  //plot plot aantal kinderen in een maand

// Back button
print "<form method=\"post\" name=\"form\" action=\"statisticsplot.php\">";
print "<center><input type=\"button\" value=\"".$gm_lang["back"]."\" onclick=\"location.href='statistics.php';\" />";
print "</center></form>";

print_footer();
?>
